from .utils import *
# from utils import *

# 获取标题点击后跳转的电影详情信息 -- get请求
def getMovieDetailData(movieId):
    tableData = df.values
    resultData = []
    for i in tableData:
        # print(i[0], movieId)
        if i[0] == movieId:
            i[17] = i[17].split(sep=' , ')
            resultData.append(list(i))
    return resultData

# 获取搜索的关键字的电影详情信息 -- post请求
def getMovieDetailSearchWordData(searchWord):
    tableData = df.values
    resultData = []
    for i in tableData:
        i[17] = i[17].split(sep=' , ')
        # 有些图片没有.jpg，添加.jpg
        imgRow = []
        for j in i[17]:
            if ".jpg" not in j:
                j = j + ".jpg"
            imgRow.append(j)
        i[17] = imgRow
        # 在电影名称中可以找到包含searchWord的字段：
        if i[1].find(searchWord) != -1:
            resultData.append(i)
    return resultData

# test
# getMovieDetailData()
# getMovieDetailSearchWordData()